from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser

llm = ChatOpenAI(
  openai_api_base="https://api.openai-proxy.org/v1",
  openai_api_key="sk-N7HqBKMQJE8FFZ1y0m5GZielsPWFATIOSGoG82zG0k2gQI9f"  
)

prompt = ChatPromptTemplate.from_messages([
  ("system","你是世界级技术专家"),
  ("user","{input}")
])

output_parser = StrOutputParser()

chain = prompt | llm | output_parser

result = chain.invoke({"input": "帮我写一篇介绍LangChain的文章，50个字。"})
print(result)